package jdbc;
import java.sql.Connection;
import java.sql.PreparedStatement;
/**
 * Created by kevin on 2020/3/25.
 */
public class AccountDao {

    /**
     * 修改指定用户的余额
     * @param connection
     * @param name
     * @param balance
     */
    public void updateBalance(Connection connection,String name,double balance){
        try{

            String sql = "update account set balance=balance+? where name=?";
            PreparedStatement preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setDouble(1,balance);
            preparedStatement.setString(2,name);
            preparedStatement.executeUpdate();
        }catch (Exception e){

        }
    }
}
